#pragma once
#include <queue>
#include <string>
#include <unordered_map>

class Command
{
public:
	virtual void execute() = 0;
	virtual void undo() = 0;
};

class CommandInvoker
{
public:
	CommandInvoker();
	~CommandInvoker();

	void execute(Command* cmd);
	void execute(std::string cmd);

	void undo();
	void undo(std::string cmd);

	void redo();
	void redo(std::string cmd);

	void InsertCommand(std::string name, Command* cmdHandle);
private:
	std::queue<Command*> CommandQueue;
	std::queue<Command*> undoQueue;
	std::unordered_map<std::string, Command*> commandMap;
};

class PrintHelloCommand : public Command
{
public:
	void execute() override;

	void undo() override;
};

class PrintWorldCommand : public Command
{
public:
	void execute() override;

	void undo() override;
};

class PrintAddCommand : public Command
{
public:
	PrintAddCommand(int a, int b) : ma(a), mb(b) {}

	void execute() override;

	void undo() override;

private:
	int ma;
	int mb;
};

